version 9
capture log close
*
set more off
*
log using MangerWP10-2012, replace text
use MangerWP10-2012.dta, clear
tsset, clear
*
************************ Results in the paper shown in tables 3 and 4 ************************ 
*
*
* first stage to predict the share of VIIT in the bilateral trade relationship
*
reg viitShare25 lndistance lnGdpProd lnGdpCapProd lnFdiProd  _I* if fullsample==1, vce(bootstrap, reps(1000) cluster(pairid) idcluster(newid) group(pairid) seed(123))
predict viit25sharehat
label var viit25sharehat "predicted share of VIIT, 25% uv"
* store these results for making tables
eststo FirstStage25, title((1))
*
* second stage to predict PTA formation 
*
logit anyPTAinforce viit25sharehat lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
* Save the results for the comparison of goodness-of-fit
*
*
fitstat, saving(viit)
* store these results for making tables
eststo bootlogit25, title((2))
*
*
* Now run the same model replacing VIIT share with the total trade (logged) on the same sample
reg lntotaltrade lndistance lnGdpProd lnGdpCapProd lnFdiProd  _I* if fullsample==1, vce(bootstrap, reps(1000) cluster(pairid) idcluster(newid) group(pairid) seed(123))
predict lntradehat
label var lntradehat "predicted trade value (ln)"
logit anyPTAinforce lntradehat lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
* Now use the fitstat to compare the saved model (viit) with the current model using total trade
*
fitstat, using(viit)
* 
* Both AIC and BIC show strong evidence in favor of the (saved) model using VIIT share instead of total trade.
*
*
* Same estimation with a lagged independent variable
* generate a lagged predicted variable
tsset pairid year
by pairid: gen viit25sharehatlagged = L.viit25sharehat
tsset, clear
label var viit25sharehatlagged "predicted share of VIIT, t-1, 25% uv"
*
*
*
* Note that this means that the samples in stages 1 and 2 are not identical
logit anyPTAinforce viit25sharehatlagged lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
*
eststo bootlogit25lagged, title((3))
*
*
* Finally, just run everything measured at t instead of t-1 to avoid post-treatment
* bias in stage 2, except for the PTA coverage variable
*
*
*********************** Make table with the central estimation results
estout FirstStage25 bootlogit25 bootlogit25lagged using MangerVIIT-PTAs-RnR-results.tex, replace cells("b se") style(mytex_logit) legend drop(_I*) nolabel
*
*
*
*
*********************** Different threshold values
*
* repeat the same for uv thresholds of 15% and 35%
*
*
* first at 35% unit value difference
reg viitShare35 lndistance lnGdpProd lnGdpCapProd lnFdiProd  _I* if fullsample==1, vce(bootstrap, reps(1000) cluster(pairid) idcluster(newid) group(pairid) seed(123))
eststo FirstStage35, title((6))
*
predict viit35sharehat
label var viit35sharehat "predicted share of VIIT, 35% uv"

logit anyPTAinforce viit35sharehat lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
eststo bootlogit35, title((7))
*
* then at 15% unit value difference
*
*
reg viitShare15 lndistance lnGdpProd lnGdpCapProd lnFdiProd  _I* if fullsample==1, vce(bootstrap, reps(1000) cluster(pairid) idcluster(newid) group(pairid) seed(123))
eststo FirstStage15, title((8))
predict viit15sharehat
label var viit15sharehat "predicted share of VIIT, 15% uv"
*
*
*
*
logit anyPTAinforce viit15sharehat lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
eststo bootlogit15, title((9))
*
*
estout FirstStage35 bootlogit35 FirstStage15 bootlogit15 using MangerVIIT-PTAs-RnR-robustness1.tex, replace cells("b se") style(mytex_logit) legend drop(_I*) nolabel
*
*

*
*
************************ Shifting the mean in both equations
* Because the variables GDP/cap-North and -South appears in both stages, we need to adjust
* the calculation of the mean + 1 stdev of the predicted value of VIITshare.
*
*
* Move GDP/cap variables to mean + 1sd in first-stage
*
reg viitShare25 lndistance lnGdpProd lnGdpCapProd lnFdiProd  _I* if fullsample==1, vce(bootstrap, reps(1000) cluster(pairid) idcluster(newid) group(pairid) seed(123))
*
* predict the value when GDP/cap North is at mean + 1sd
prvalue, x(lnGdpCapProd =19.4022533) rest(mean)
* Predicted zhat: 5.343 
*
* predict the value when GDP/cap South is at mean + 1sd
prvalue, x(lnGdpCapProd =19.62248) rest(mean)
* predicted zhat: 5.2748
*
*
*
************************ Illustration of results
*
*
logit anyPTAinforce viit25sharehat lndistance democNorth_t democSouth_t alliance_t gattwtomemb_t mtnround lnGDPcapNorth lnGDPcapSouth  tradecoverageanyPTANorth tradecoverageanyPTASouth  if fullsample==1, vce(bootstrap, cluster(pairid) reps(1000) seed(123))
*
* First, calculate the point prediction of the probability change, or the "relative risk".
* Confidence intervals are given in the table
*
*
*
** regular confidence intervals
*
*
*
*
foreach v in viit25sharehat lndistance democNorth_t democSouth_t gattwtomemb_t tradecoverageanyPTANorth tradecoverageanyPTASouth {
	qui summarize `v'
	local start = r(mean)
	local end = r(mean) + r(sd)
	di n "** Change from `start' to `end' in `v'"
	qui prvalue, x(`v' = `start') rest(mean) save
		prvalue, x(`v' = `end') dif brief
}

foreach v in lnGDPcapNorth {
	qui summarize `v'
	local start = r(mean)
	local end = r(mean) + r(sd)
	di n "** Change from `start' to `end' in `v'"
	qui prvalue, x(viit25sharehat=5.343 `v' = `start') rest(mean) save
		prvalue, x(viit25sharehat=5.343 `v' = `end') dif brief
}

foreach v in lnGDPcapSouth {
	qui summarize `v'
	local start = r(mean)
	local end = r(mean) + r(sd)
	di n "** Change from `start' to `end' in `v'"
	qui prvalue, x(viit25sharehat=5.2748 `v' = `start') rest(mean) save
		prvalue, x(viit25sharehat=5.2748 `v' = `end') dif brief
}

foreach v in alliance_t mtnround {
	di n "** Change from `start' to `end' in `v'"
	qui prvalue, x(`v' = 0) rest(mean) save
		prvalue, x(`v' = 1) dif brief
}
*
mfx
* 
*
*
*
*
*
log close




